﻿<UserControl x:Class="GSF.PhasorProtocols.UI.UserControls.ChartWindowUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:tsf="clr-namespace:GSF.TimeSeries.UI;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"             
             xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"              
             xmlns:my="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="700" Height="450" Width="650">

    <UserControl.Resources>

    <ControlTemplate x:Key="ChartTemplate" TargetType="chartingToolkit:Chart">
            <Border Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Padding="{TemplateBinding Control.Padding}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid Grid.Row="1" Margin="0,15">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <visualizationToolkit:Legend Grid.Column="1" Name="Legend" Style="{TemplateBinding chartingToolkit:Chart.LegendStyle}" Title="{TemplateBinding chartingToolkit:Chart.LegendTitle}" />
                        <my:EdgePanel Name="ChartArea" Style="{TemplateBinding chartingToolkit:Chart.ChartAreaStyle}">
                            <Grid Panel.ZIndex="-1" Style="{TemplateBinding chartingToolkit:Chart.PlotAreaStyle}" />
                            <Grid Name="PlotArea" Background="Transparent" Panel.ZIndex="1" MouseLeftButtonDown="PlotArea_MouseLeftButtonDown" Cursor="Cross" />
                            <Border BorderBrush="#FF919191" BorderThickness="1" Panel.ZIndex="10" />
                        </my:EdgePanel>
                    </Grid>
                </Grid>
            </Border>
        </ControlTemplate>
    </UserControl.Resources>

    <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar BorderBrush="DarkGray" Background="GhostWhite" BorderThickness="1">
                <ToolBar.Resources>
                    <Style TargetType="{x:Type Image}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                <Setter Property="Opacity" Value="0.50" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ToolBar.Resources>
                <Button Width="23" Height="23" IsEnabled="False" Name="m_backButton" Click="BackButton_Click" ToolTip="Back" ToolTipService.ShowOnDisabled="True">
                    <Image Source="/GSF.TimeSeries.UI;component/Images/ArrowLeftBlue.png" />
                </Button>
                <Button Width="23" Height="23" IsEnabled="False" Name="m_forwardButton" Click="ForwardButton_Click" ToolTip="Forward" ToolTipService.ShowOnDisabled="True">
                    <Image Source="/GSF.TimeSeries.UI;component/Images/ArrowRightBlue.png" />
                </Button>
                <Separator />
                <Button Width="23" Height="23" ToolTip="Zoom in" Click="ZoomInButton_Click">
                    <Image Source="/GSF.TimeSeries.UI;component/Images/ZoomIn.png" />
                </Button>
                <Button Width="23" Height="23" ToolTip="Zoom out" Click="ZoomOutButton_Click">
                    <Image Source="/GSF.TimeSeries.UI;component/Images/ZoomOut.png" />
                </Button>
                <Button Width="23" Height="23" ToolTip="Zoom fit" Click="ZoomFitButton_Click">
                    <Image Source="/GSF.TimeSeries.UI;component/Images/FitToSize.png" />
                </Button>
            </ToolBar>
        </ToolBarTray>
        <chartingToolkit:Chart DataContext="1,10 2,20 3,30 4,40" Name="m_chart" Template="{StaticResource ChartTemplate}" DockPanel.Dock="Bottom" LegendTitle="Archives">
            <chartingToolkit:Chart.Axes>
                <chartingToolkit:DateTimeAxis Orientation="X" Location="Bottom" Name="m_xAxis" />
                <chartingToolkit:LinearAxis Orientation="Y" ShowGridLines="True" Name="m_yAxis" />
            </chartingToolkit:Chart.Axes>
        </chartingToolkit:Chart>
    </DockPanel>
</UserControl>

